package com.xbongbong.crm.util;

import com.xbongbong.paas.domain.entity.ext.ConditionsEntityExt;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.saas.enums.business.ClueEnum;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author 吴峰
 * @date 2022/07/04 9:02
 */
public class PublicPoolUtil {

    public static void setPublicClue(FormDataListDTO formDataListDTO) {
        List<ConditionsEntityExt> conditionList = formDataListDTO.getConditions();
        conditionList = conditionList == null ? new ArrayList<>() : conditionList;
        for (ConditionsEntityExt entityExt : conditionList){
            if (Objects.equals(entityExt.getAttr(), ClueEnum.OWNER_ID.getAttr())){
                entityExt.setFieldType(FieldTypeEnum.PRE_OWNER_ID.getType());
                entityExt.setAttr(FieldTypeEnum.PRE_OWNER_ID.getAlias());
            }
        }
        formDataListDTO.setDefaultGroup(2);
    }
}
